﻿Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D
Imports Commander_Wars.Spieletools
Public Class LandschaftstexturRiff
    Inherits ObjektLandschaftsTextur
    Dim Riff As Objekt3D


    Public Sub New()
        ID = "RIFF"
        Landschaftsname = "Riff"
        Select Case DataSettings.TerrainStyle
            Case TerrainStyle.AdvanceWarsDC
                Deckung = 2
                Frame = False
            Case Else
                Frame = True
                Deckung = 1
        End Select

        Tarnung = True
        KP = -1
        If DataSettings.draw3D Then
            TexturenLaden(New String() {"Riff+N+O+S+W"})
        Else
            Select Case DataSettings.TerrainStyle
                Case TerrainStyle.CommanderWars2, TerrainStyle.AdvanceWarsDC
                    TexturenLaden(New String() {"Riff+N+O+S+W", "Riff1+N+O+S+W", "Riff2+N+O+S+W", "Riff3+N+O+S+W"})
                Case Else
                    TexturenLaden(New String() {"Riff+N+O+S+W"})
            End Select
        End If

        Normal = -1
        UebergaengeLaden("Kueste")
        Ausrichtungslandschaften = New String() {"SEE", "STRAND", "RIFF", "BRUECKE", "ZUGBRUECKE", "BAUBRUECKE", "RAUESEE", "NEBEL"}


        If DataSettings.draw3D Then
            Ini3D()
        End If
    End Sub
    Public Overrides Function BildID(ByVal X As Integer, ByVal Y As Integer, ByVal Spielfeld As ObjektSpielfeld, Optional ByVal Untergund As Boolean = False) As Integer
        Dim Bild As Integer = MyBase.BildID(X, Y, Spielfeld)
        If Bild >= 0 Then
            Return Zufallszahl(0, Texturen.Length - 1)
        Else
            Return Bild
        End If
    End Function
    Public Overrides Function DrawSpecialStyle(ByVal BildID As Integer, ByVal Fog As Nebelarten, ByVal Alpha As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal TerrainUntergrundID As Integer, ByVal TerrainUntergrundBildID As Integer, ByVal TerrainUntergrundID2 As Integer, ByVal TerrainUntergrundBildID2 As Integer, Optional ByVal FixedLocation As Boolean = False, Optional ByVal Top As Boolean = False) As Boolean
        Select Case DataSettings.TerrainStyle
            Case CommanderWarsGameModi.CommanderWars2, CommanderWarsGameModi.AdvanceWarsDC
                Return DrawTerrainUndUntergrund(Alpha, Fog, BildID, X, Y, 0, 0, TerrainUntergrundID, TerrainUntergrundBildID, TerrainUntergrundID2, TerrainUntergrundBildID2, FixedLocation, Top)
            Case Else
                Return DrawTerrainUndUntergrund(Alpha, Fog, BildID, X, Y, ObjektLandschaft.Frame, 4, TerrainUntergrundID, TerrainUntergrundBildID, TerrainUntergrundID2, TerrainUntergrundBildID2, FixedLocation, Top)
        End Select
    End Function

    Public Overrides Sub Malen3D(ByVal p_MatCube As Microsoft.DirectX.Matrix, ByVal Landschaft As ObjektLandschaft)
        Malen3D(p_MatCube, "See", Landschaft) 'ganz normales Meer malen

        'und dann ein paar Riffe draufzeichnen.
        Riff.Malen(p_MatCube)
        'Grafikengine.Grafikkarte.SetTexture(0, TexturRiff)
        'Dim standardMatrix As Matrix = Grafikengine.Grafikkarte.Transform.World
        'Grafikengine.Grafikkarte.Transform.World = p_MatCube
        'Grafikengine.Grafikkarte.VertexFormat = CustomVertex.PositionTextured.Format

        ''Riff 1:
        'Dim cube(4) As CustomVertex.PositionTextured
        'cube(0) = New CustomVertex.PositionTextured(0.23, 0.0, 0.13, 1, 1)
        'cube(1) = New CustomVertex.PositionTextured(0.16, 0.0, 0.21, 0, 1)
        'cube(2) = New CustomVertex.PositionTextured(0.16, 0.1, 0.13, 0.5, 0)
        'cube(3) = New CustomVertex.PositionTextured(0.08, 0.0, 0.07, 1, 1)
        'cube(4) = New CustomVertex.PositionTextured(0.23, 0.0, 0.13, 0, 1)
        'Grafikengine.Grafikkarte.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, cube)

        ''Riff 2:
        'cube(0) = New CustomVertex.PositionTextured(0.83, 0.0, 0.67, 1, 1)
        'cube(1) = New CustomVertex.PositionTextured(0.85, 0.0, 0.79, 0, 1)
        'cube(2) = New CustomVertex.PositionTextured(0.8, 0.08, 0.72, 0.5, 0)
        'cube(3) = New CustomVertex.PositionTextured(0.72, 0.0, 0.73, 1, 1)
        'cube(4) = New CustomVertex.PositionTextured(0.83, 0.0, 0.67, 0, 1)
        'Grafikengine.Grafikkarte.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, cube)

        ''Riff 3:
        'cube(0) = New CustomVertex.PositionTextured(0.21, 0.0, 0.8, 1, 1)
        'cube(1) = New CustomVertex.PositionTextured(0.2, 0.0, 0.93, 0, 1)
        'cube(2) = New CustomVertex.PositionTextured(0.16, 0.03, 0.86, 0.5, 0)
        'cube(3) = New CustomVertex.PositionTextured(0.1, 0.0, 0.85, 1, 1)
        'cube(4) = New CustomVertex.PositionTextured(0.21, 0.0, 0.8, 0, 1)
        'Grafikengine.Grafikkarte.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, cube)


        ''Wieder den Ursprungsstatus wiederherstellen..
        'Grafikengine.Grafikkarte.Transform.World = standardMatrix
    End Sub

    Public Overrides Sub Ini3D()
        Riff = New Objekt3D
        Riff.MeshBildLaden(DataSettings.Resourcenpfad + "Terrain\Meshes\Riff.x")
    End Sub

    Public Overrides Sub Tick()

    End Sub

    Public Overrides Function GetTerrainUntergrund() As String()
        Return New String() {"SEE"}
    End Function
End Class
